#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>

using namespace std;

int MyAtoi(string str) 
{
	int i = 0;
	int res = 0;
	int flag = 1;
	int MAX = INT_MAX / 10;
	int length = str.size();
	while (str[i] == ' ')
	{
		++i;
		if (i > length)
		{
			return 0;
		}
	}
	if (str[i] == '-')
	{
		flag = -1;
		++i;
	}
	else if (str[i] == '+')
	{
		++i;
	}
	while (i < length)
	{
		if (str[i] > '9' || str[i] < '0')
		{
			break;
		}
		if (res > MAX || (res == MAX && str[i] > '7'))
		{
			return flag == 1 ? INT_MAX : INT_MIN;
		}
		res = res * 10 + (str[i] - '0');
		++i;
	}
	return res * flag;
}

int main()
{
	string str;
	getline(cin, str);
	cout << str << endl;
	int i = MyAtoi(str);
	cout << i << endl;
}